<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>CK宠物网  个人空间  认证买家资格</title>
    <jsp:include page="top_utils.jsp"></jsp:include>
    <script src="${pageContext.request.contextPath}/jquery/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/myplace.css"/>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/myspace.css">
  </head>
  
  <body>
 	<!-- 头部-->
	<div class="headnav">
		<div class="topBar">
			<div class="topBarL">
				<jsp:include page="logo.jsp"></jsp:include>
				<div class="nav">
					<ul>
						<li>
							<a href="${pageContext.request.contextPath }/">首页</a>
						</li>
						<li>
							<a href="${pageContext.request.contextPath }/news/">新闻</a>
						</li>
						<li>
							<a href="${pageContext.request.contextPath }/adopt/">领养</a>
						</li>
						<li>
							<a href="${pageContext.request.contextPath }/knowledge/">知识</a>
						</li>
						<li>
							<a href="${pageContext.request.contextPath }/shopping/">商城</a>
						</li>
					</ul>
				</div>
			</div>

			<jsp:include page="topBarR.jsp"></jsp:include>
		</div>
	</div>
 	
	<div id="main" style="background:url('/dogstore/images/${user.backimg}')  no-repeat center top;">
	  <jsp:include page="my_top.jsp"></jsp:include>
	  
	  <div class="layout-body">
	    <div class="w960  clf">   
	      <div class="m_main">
	        <div class="inner centers_mr"> 
	     		<div class="public_m2">认证卖家申请</div>
	     		<div class="tip_notem">
	            	<ul>
	                	<li>1. 绑定手机后可直接通过短信接受安全验证等重要操作。</li>
	                    <li>2. 更改手机时，请通过安全验证后重新输入新手机号码绑定。</li>
	                    <li>3. 收到安全验证码后，请在30分钟内完成验证。</li>
	                    <li>4. 信息一旦绑定就不可修改，请慎重。</li>
	                    <li>5. 等待系统管理员审核。</li>
	                </ul>
	            </div>
	            <div class="public_m4">
	            	<p>
	                	<em>认证性质：</em>
	                    <input type="radio" id="single" name="saletype" value="0" class="sex_m"><i>个体</i>
	                    <input type="radio" id="nosingle" name="saletype" value="1" class="sex_m"><i>组织</i>
	                </p>
	                <p>
	                	<em>负责人真实姓名：</em>
	                    <input type="text" name="realname" id="realname" class="sex_m" >
	                </p>
	                <p>
	                	<em>组织名称：</em>
	                    <input type="text" name="salename" id="salename" value class="sex_m" >
	                </p>
	            	<p>
	                	<em>绑定手机号码：</em>
	                    <input type="text" name="phone" id="phone" class="sex_m" >
	                    <a href="javascript:" type="button" id="btnsj" class="btn_mfyzm" style=" border:1px solid #c8c8c8; margin-left:6px">获取验证码</a>
	                </p>
	                <p>
	                	<em>收到的验证码：</em>
	                    <input type="text" class="sex_m" >
	                </p>
	                <a href="javascript:" id="sub" class="public_m3">提交申请</a>
	            </div>
	        </div>
	      </div>
	    </div>
	  </div>
	</div>
	
	<jsp:include page="footer.jsp"></jsp:include>
  </body>
  <script type="text/javascript" src="${pageContext.request.contextPath }/js/head.js"></script>
  <script type="text/javascript">
  	$(document).ready(function(){
  		//如果选择个体，就不填组织
  		$("#single").on("click",function(){
 			$("#salename").attr("value","个体不需要填写");
 			$("#salename").attr("disabled","true");
  		});
  		//如果选择组织，就恢复
  		$("#nosingle").on("click",function(){
  			$("#salename").attr("value","");
  			$("#salename").removeAttr("disabled");	
  		});
  	
  		$("#sub").on("click",function(){
  			var index = layer.load(2, {time: 10000}); //缓冲10秒
  			//获取填写的值
  			var saletype = $("input[name='saletype']:checked").val();
  			var realname = $("#realname").val();
  			var salename = $("#salename").val();
  			var phone = $("#phone").val();
  			
  			//校验数据	
  			//1.非空校验
  			var isnull = true;
  			if(saletype == null || saletype == ''){
  				layer.close(index);
				layer.msg("认证性质不能不选!", {shift:6});
				return false;		
			}
			isnull = isNull("salename","认领名称") && isnull;
			isnull = isNull("realname","真实姓名") && isnull;
			isnull = isNull("phone","手机号") && isnull;
			
			//手机格式校验
			var re=/^1[3|5|8][0-9]\d{8}$/;
			if(!re.test(phone)){
				layer.close(index);
				layer.tips("手机格式错误!", "#phone",{tipsMore: true,tips: [2, '#78BA32']});
				return false;
			}
			
			if(isnull == false){
				layer.close(index);
				return false;
			}else{
				//提交给后台
		  		$.ajax({
					type:"POST",
					dataType:"json",
					data:{
						saletype:saletype,
						realname:realname,
						salename:salename,
						phone:phone
						},
					url:"/dogstore/user/addrzinfo.action",
					success:function(error){
						if(error == "0"){
							layer.close(index);
							layer.msg("提交申请成功!",{icon: 1,shift: 2});
							setTimeout(function (){
								//关闭弹窗
								layer.close(index); 
								//刷新
								window.location.reload();
							},1000);
						}else{
							layer.close(index);
							layer.msg("提交申请失败-500!",{icon: 2,shift: 6});
							setTimeout(function (){
								//关闭弹窗
								layer.close(index); 
							},1000);
						}
					},
					error:function(){
						layer.close(index);
						layer.msg("登录提交失败!请联系prince..",{shift: 6});	
					}
				});
			}		
  		});
  	});
  	
  	function isNull(name,error){
	    var isnull = true;
	    var value = $("#"+name).val().trim();
		if(value == "" || value == null){
			layer.tips(error+"不能为空!", "#"+name,{tipsMore: true,tips: [2, '#78BA32']});
			isnull = false;
		}
		return isnull;
	}
  </script>
</html>
